【DASCTF】4道逆向题解析
本文为看雪论坛优秀文章
看雪论坛作者ID:BIX
目录
T0p Gear easy_maze Magia 521T0p Gear
明明是一道签到题,就应该想到简单的,开始在哪里规规矩矩的分析完整个程序……也是复杂,有一个AES加密。
其实找到地址,直接GDB动调就好了……
64位elf文件加了upx壳,脱壳后载入ida中发现伪代码不好看,就直接看汇编。就三个检查函数。
总结:对程序还是要看的长远一点吧。
easy_maze
比签到题来好多了。
64位elf文件,载入ida中看一下,知道是迷宫题,所以目标是明确的。
可以知道刚开始列和行都是0,下面找迷宫图。先随便看一个操作函数。
查看byte_400AE0:把数据提取出来。
用C语言将图打印出来:
#include <stdio.h>
int main(void)
{
int i = 0, j = 0;
char ida_chars[] =
{
49, 79, 79, 79, 79, 49, 49, 49, 49, 35,
49, 49, 49, 79, 79, 49, 79, 79, 79, 79,
79, 79, 49, 79, 79, 49, 49, 49, 49, 79,
79, 49, 49, 79, 79, 79, 79, 79, 49, 79,
79, 49, 79, 79, 79, 79, 49, 49, 49, 79,
79, 49, 49, 79, 79, 49, 49, 79, 79, 79,
79, 79, 49, 79, 79, 49, 79, 79, 79, 79,
79, 79, 49, 49, 49, 49, 79, 79, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79
};
for(i = 0; i < 10; i++)
{
for(j = 0; j < 10; j++)
printf("%c ", ida_chars[10*i+j]);
putchar(10);
}
return 0;
}
由于0和O不易区别,自己把0换成了1。最后从1绕过O走到#即可。jkkjjhjjkjjkkkuukukkuuhhhuukkkk 再md5加密一下。
总结:无,不是新套路。
Magia
没看见题目的提示,在找密码的时候所有情况试的……
32位PE文件,首先打开看了下, 提示输入一个密码,然后验证,ida中看看。
接着看下面:
用限制条件写爆破试试:
#include <stdio.h>
int main(void)
{
int i = 0, j = 0, k = 0, v5 = 0, y = 0;
char flag[33] = {0}, temp = 0;
char v11[] = {14, 5, 0, 11, 13, 9, 2, 3, 12, 5, 15, 1, 14, 4, 15, 13, 1, 8, 15, 15, 9, 3, 15, 14, 15, 4, 15, 6, 2, 5, 5, 13};
char v43[] = {76, 101, 96, 114, 100, 73, 112, 99, 108, 69, 83, 97, 78, 100, 72, 97};
char v59[] = {51, 0, 21, 9, 11, 54, 6, 12, 2, 58, 44, 8, 49, 11, 55, 12};
for(i = 31; i > v5; i--)
{
for(j = 33; j < 127; j++)
{
if((j & 0xf) == v11[i])
for(k = 33; k < 127; k++)
{
if((k & 0xf) == v11[v5])
{
if((k^j) == v59[v5] && (k&j) == v43[v5])
{
flag[i] = j, flag[v5] = k;
}
}
}
}
v5++;
}
puts(flag);
return 0;
}
可以看到,情况是不唯一的,不然开始就会是Nep了。
先接着往下看看:
开始找重写的sub_403000()函数。
先得到key[14]的所有情况:
#include <stdio.h>
int main(void)
{
int i = 0, j = 0;
char v11[] = {14, 5, 0, 11, 13, 9, 2, 3, 12, 5, 15, 1, 14, 4, 15, 13, 1, 8, 15, 15, 9, 3, 15, 14, 15, 4, 15, 6, 2, 5, 5, 13};
char v43[] = {76, 101, 96, 114, 100, 73, 112, 99, 108, 69, 83, 97, 78, 100, 72, 97};
char v59[] = {51, 0, 21, 9, 11, 54, 6, 12, 2, 58, 44, 8, 49, 11, 55, 12};
for(i = 32; i < 127; i++)
{
if((i&0xf) == v11[14])
for(j = 32; j < 127; j++)
{
if((j&0xf) == v11[31-14])
{
if(((i^j) == v59[14]) && ((i&j) == v43[14]))
printf("%c%c ", i, j);
}
}
}
return 0;
}
因为是成对的,将之前的得到的不唯一的key,指定位置换成这3对字符。
然后载入OD,依次试一下,发现当Ox与oX都会报错,而_h正常执行。
得到此时的程序状态后dump出来。
dump出的文件,载入ida看一下重写的函数的功能。
因为没看题目提示,使用之前找key[14]的办法,所有情况解出后看key怎么顺眼。最后得到:Nep{mircle_and_maho_is_not_free}。
其实题目给了格式的提示……
再记录下ida中v35[i] = ......语句的地址,进入OD中下断点,然后输入正确的key,得到最终flag:
总结:看提示吧……
521
又是C++语法类的逆向,发现最近好多都是……
64位elf文件,运行看一下,直接让输入flag然后验证。
还是载入ida:
进入v4 = sub_55FE07F79864(a4, (__int64)&v8):
接着看下面:
上面标黄的是整个题的关键函数,进入:
ida动调提取出数据表:
最后exp:
#include <stdio.h>
int main(void)
{
unsigned char ida_chars[] =
{
128, 255, 255, 255, 255, 255, 255, 255, 89, 0,
0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
0, 0, 0, 0, 53, 0, 0, 0, 0, 0,
0, 0, 34, 0, 0, 0, 0, 0, 0, 0,
115, 0, 0, 0, 0, 0, 0, 0, 141, 255,
255, 255, 255, 255, 255, 255, 26, 0, 0, 0,
0, 0, 0, 0, 81, 0, 0, 0, 0, 0,
0, 0, 93, 0, 0, 0, 0, 0, 0, 0,
48, 0, 0, 0, 0, 0, 0, 0, 232, 255,
255, 255, 255, 255, 255, 255, 87, 0, 0, 0,
0, 0, 0, 0, 38, 0, 0, 0, 0, 0,
0, 0, 246, 255, 255, 255, 255, 255, 255, 255,
7, 0, 0, 0, 0, 0, 0, 0, 198, 255,
255, 255, 255, 255, 255, 255, 146, 255, 255, 255,
255, 255, 255, 255, 94, 0, 0, 0, 0, 0,
0, 0, 220, 255, 255, 255, 255, 255, 255, 255,
131, 255, 255, 255, 255, 255, 255, 255, 31, 0,
0, 0, 0, 0, 0, 0, 118, 0, 0, 0,
0, 0, 0, 0, 146, 255, 255, 255, 255, 255,
255, 255, 37, 0, 0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 0, 0, 0, 0, 101, 0,
0, 0, 0, 0, 0, 0, 251, 255, 255, 255,
255, 255, 255, 255, 46, 0, 0, 0, 0, 0,
0, 0, 77, 0, 0, 0, 0, 0, 0, 0,
107, 0, 0, 0, 0, 0, 0, 0, 69, 0,
0, 0, 0, 0, 0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 135, 255, 255, 255, 255, 255,
255, 255, 233, 255, 255, 255, 255, 255, 255, 255,
159, 255, 255, 255, 255, 255, 255, 255, 34, 0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 0x23, 0x11, 0x37, 0x21,
0x1E, 0xBB, 0x17, 0xD2, 0xB3, 0xDE, 0x2C, 0x63, 0x64, 0x09,
0x78, 0x61, 0xCB, 0xAD, 0x9A, 0xA4, 0xF3, 0x0A, 0xA0, 0x14,
0xF2, 0x92, 0x0D, 0x5E, 0xA9, 0xD5, 0x90, 0x96, 0x6F, 0x36,
0xFD, 0x76, 0x45, 0xDA, 0x01, 0xF5, 0x0F, 0xB6, 0x34, 0x3A,
0xDD, 0xD0, 0xD7, 0xAC, 0xFB, 0x80, 0xDF, 0x27, 0x13, 0x93,
0x87, 0x72, 0x89, 0x49, 0x73, 0x71, 0x7D, 0x06, 0x9D, 0x00,
0x83, 0xE8, 0xC2, 0x75, 0xAE, 0xF7, 0x97, 0x60, 0xE1, 0xD9,
0x2F, 0x6E, 0x4B, 0x31, 0xE9, 0x43
};
int i = 0, v6 = 0, v7 = 0, v5 = 0, ans[37] = {0}, j = 0;
char flag[37] = {0};
for(i = 0; i < 296; i += 8)
{
ans[j++] = *(long int *)(&ida_chars[i]);
}
for(i = 0; i < 37; i++)
{
v6 = (unsigned char)(((unsigned int)((signed int)(v6 + 1) >> 31) >> 24) + v6 + 1) - ((unsigned int)((signed int)(v6 + 1) >> 31) >> 24);
v5 = (unsigned int)((v7 + a[v6]) >> 31) >> 24;
v7 = (unsigned char)(v5 + v7 + a[v6]) - v5;
int temp = a[v6];
a[v6] = a[v7];
a[v7] = temp;
flag[i] = ans[i]^a[(unsigned char)(a[v6] + a[v7])];
}
puts(flag);
return 0;
}
ps. 题目附件请点击“阅读原文”下载~
看雪ID:BIX
https://bbs.pediy.com/user-891547.htm
*本文由看雪论坛 BIX 原创,转载请注明来自看雪社区。
推荐文章++++
* CVE-2019-0803 For windows 2012R2
好书推荐